package com.cloud.springcloud.service.impl;

import com.cloud.springcloud.service.IMessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @auther hxx
 * @create 2020-02-22 10:56
 */


@EnableBinding(Source.class)
public class MessageProviderImpl implements IMessageProvider {


    @Resource
    private MessageChannel output; // 消息发送管道

    @Override
    public String send() {
        String s = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(s).build());
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>" + s);
        return null;
    }
}
